const _products = [
    { "id": 1, "title": "红富士苹果电脑", "price": 8888.88, "inventory": 2 },
    { "id": 2, "title": "机械手感键盘", "price": 30, "inventory": 10 },
    { "id": 3, "title": "一张过去的CD", "price": 102.2, "inventory": 5 },
    { "id": 4, "title": "无用良品", "price": 65, "inventory": 5 },
]

export default {
    getProducts(fun) {
        setTimeout(() => fun(_products), 100)
    },

    buyProducts(products, fun, errorFun) {
        setTimeout(() => {
            (Math.random() > 0.5 || navigator.userAgent.indexOf('PhantomJS') > -1)
                ? fun()
                : errorFun()
        }, 100)
    }
}